<template>
    <div
        :class="['lg-loading', {'is-fullscreen': fullscreen}, {[customClass]:customClass}, {visible}]"
        :style="`background-color: ${background ? background : 'rgba(0, 0, 0, .7)'};`"
    >
        <i :class="['iconfont', spinner ? spinner : 'icon-loading']"></i>
        <span v-if="text">{{text}}</span>
    </div>
</template>

<script>
export default {
    name: 'lgLoading',
    data() {
        return { 
            text: null,
            spinner: null,
            background: null,
            fullscreen: true,
            visible: false,
            customClass: ''
        }
    }
}
</script>

<style lang="less" scoped>
@keyframes myfirst {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(350deg);
  }
}
.lg-loading{
    position: relative;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 9901;
    visibility: hidden;
    display: flex;
    opacity: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all .3s;
    i{
        font-size: 36px;
        color: #fff;
        animation: myfirst 2s linear infinite;
    }
    span{
        margin-top: 7px;
        letter-spacing: 2px;
        color: #fff;
        font-size: 15px;
    }
}
.is-fullscreen{
    position: fixed;
    height: 100vh;
}
.visible{
    opacity: 1;
    visibility: visible;
}
</style>